package router

import (
	"auth-service/internal/api/auth"
	"github.com/danfwing/sd-project/pkg/middleware"
	"github.com/danfwing/sd-project/pkg/server"
	"github.com/danfwing/sd-project/pkg/utils"
	"github.com/gin-gonic/gin"
)

// InitRouter 初始化路由
func InitRouter(s *server.Server) {
	r := s.Engine()
	// 健康检查
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	r.POST("/api/refresh", utils.API(middleware.RefreshTokenHandler))
	// API 版本 v1
	v1 := r.Group("/api/v1")
	{
		// 注册各个模块的路由
		auth.RegisterRoutes(v1)
	}
}
